package com.charactereducation.pitchpalace.service;

import com.charactereducation.module.vo.User;
import com.charactereducation.tools.GenerateID;
import com.charactereducation.tools.myRunTime.MyRunTimeExcption;
import com.charactereducation.tools.redis.RedisUtil;
import com.charactereducation.tools.result.ReturnCode;
import com.charactereducation.webcore.service.ServiceBase;
import org.apache.commons.lang.StringUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;
import java.util.Map;

/**
 * Created by Baggio on 2019-2-14.
 */
@Service
public class UserServiceImpl extends ServiceBase implements UserService {
    @Autowired
    private RedisUtil redisUtil;
private final static Long EXPIRATION =60L*5L;
    @Override
    public User getUserById(Long userId) throws MyRunTimeExcption {
        return null;
    }

    @Override
    public User Login(String phone, String passWord) throws MyRunTimeExcption {
        return null;
    }

    @Override
    public User register(User user) throws MyRunTimeExcption {
        return null;
    }

    @Override
    public void resetPasword(String phone) throws MyRunTimeExcption {

    }

    @Override
    public void modifyUser(User user) throws MyRunTimeExcption {

    }

    @Override
    public List<User> getUserList(Map<String, String> map) throws MyRunTimeExcption {
        return null;
    }

    @Override
    public String getSMSCode(String phone) throws MyRunTimeExcption {
        if (StringUtils.isBlank(phone)) {
            throw new MyRunTimeExcption(ReturnCode.USER_PHONE_IS_NULL);
        }
        String code = GenerateID.getRandomNum(6, true);
        redisUtil.set(phone,code,EXPIRATION);
        return code;
    }
}
